<header class="mui-bar mui-bar-nav header">
  <a class="mui-action-back mui-icon mui-pull-left" href=""><i class="iconfont">&#xe602;</i></a>
  <h1 class="mui-title">绑定手机号</h1>
  <a class="mui-action-back mui-icon mui-pull-right" href="search.html"><i class="iconfont">&#xe601;</i></a>
</header>
<div class="mui-content">
  <div class="pay-iphone">请您输入姓名与手机号方便与您联系</div>
  <input type="text" placeholder="姓名" class="login-password" name="name">
  <input type="text" placeholder="手机号" class="login-password" name="phone">
  <input type="button" class="login-btn" value="确认">
  <div class="bound-text">
    <p>请正确填写手机号与姓名</p>
  </div>
</div>
<script>
  $('.login-btn').click(function () {
    var phone_number = $('input[name="phone"]').val();
    var name = $('input[name="name"]').val();
    if (phone_number == null || phone_number == ''){
        mui.toast('请输入正确的手机号');
    }
    var openid = '<%= user_info.openid%>';
    var remark = {
        headimgurl: '<%= user_info.headimgurl%>',
        nickname: '<%= user_info.nickname%>',
    };
    var json = {
      source: 'wechat',
      source_id: openid,
      name: name,
      tel: phone_number,
      addr: '',
      id_no: '',
      remark: JSON.stringify(remark)
    };

    console.log(json);
    $.post('/bind_phone/', json, function (call) {
      console.log(call);
      window.location.href = '/login';
    })
  })
</script>
